import threading
import enum
# ----------------------------------------
# --------------------------------------------------


def checker(task_info):
    job, task = task_info
    # --------------------------------------------------
    pass


class Task(dict):

    def __init__(self, job, task_id, ckr, args=None, kwargs=None):
        super().__init__()
        self.id = task_id
        # --------------------------------------------------
        self._status = False                  # The task is unfinished default
        self._statuslock = threading.RLock()  #
        # --------------------------------------------------
        self._itemlock = threading.RLock()    #
        # --------------------------------------------------
        self._job = job
        self._checker = ckr
        self._args = args or {}
        self._kwargs = kwargs or {}

    def check(self):
        if not self._checker:
            return False
        # --------------------------------------------------
        if not self._checker(*self._args, **self._kwargs):
            return False
        # --------------------------------------------------
        with self._statuslock:
            self._status = True
        return True

    @property
    def is_finished(self):
        with self._statuslock:
            return self._status

    def __setitem__(self, key, value):
        with self._itemlock:
            super().__setitem__(key, value)

    def __getitem__(self, item):
        with self._itemlock:
            super().__getitem__(item)

    def __delitem__(self, key):
        with self._itemlock:
            super().__delitem__(key)

    def get(self, key):
        with self._itemlock:
            super().get(key)

    def pop(self, key):
        with self._itemlock:
            super().pop(key)


if __name__ == '__main__':
    task = Task('1910070001-1-2-3', 'sideface')
